<?php 
require_once("../config_DB/config_bd_sqlite.php"); 

//Inicializar una sesion de PHP
session_start();
 
//Validar que el usuario este logueado y exista un UID
if ( ! ($_SESSION['autenticado'] == 'SI' && isset($_SESSION['uid'])) )
{
?>
<form name="formulario" method="post" action="../../index.php">
            <input type="hidden" name="msg_error" value="2">
        </form>
        <script type="text/javascript">
            document.formulario.submit();
        </script>
<?php
}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<script src="../../js/jquery-2.0.3.min.js"></script>
		<script src="../../js/calendar.min.js"></script>
		<script src="../../js/jquery.colorbox-min.js"></script>
		<link href="../../css/calendar.min.css" rel="stylesheet">
		<link href="../../css/colorbox.css" rel="stylesheet">
	</head>
	<body>
		<div class="calendar" data-color="normal">
			<?php
			
			$query_eventos=$db->query("select id,fecha, hora,cliente, telefono, vehiculo, mantenimiento  from tcalendario where 1 order by fecha asc");
			if ($eventos=$query_eventos->fetch_array())
			{
				do
				{
				?>
				<div data-role="day" data-day="<?php $fecha=explode("-",$eventos["fecha"]); echo $fecha[0].intval($fecha[1]).intval($fecha[2]); ?>">
					<div data-role="event" data-idevento="<?php echo $eventos["id"]; ?>"
					data-name="<?php echo "Cliente: "." "; echo utf8_encode($eventos["cliente"]);echo "<br>";
					echo "Telefono: "." "; echo utf8_encode($eventos["telefono"]);echo "<br>";
					echo "Vehiculo: "." "; echo utf8_encode($eventos["vehiculo"]);echo "<br>";
					echo "Detalle de mantenimiento: "." "; echo utf8_encode($eventos["mantenimiento"]);echo "<br>";
					echo "Hora: "." ";echo utf8_encode($eventos["hora"]);?>" ></div>
				</div>
				<?php
				}
				while($eventos=$query_eventos->fetch_array());
			}
			?>
			<!--<div data-role="day" data-day="<?php echo date("Ynd",mktime(0,0,0,date("m"),date("d")+1,date("Y"))); ?>">
				<div data-role="event" data-name="Soy un evento que siempre saldr&eacute; ma&ntilde;ana" data-start="9.00" data-end="9.30" data-location="martiniglesias.eu"></div>
			</div>-->
		</div>
	<script>
	var yy;
	var calendarArray =[];
	var monthOffset = [6,7,8,9,10,11,0,1,2,3,4,5];
	var monthArray = [["ENE","Enero"],["FEB","Febrero"],["MAR","Marzo"],["ABR","Abril"],["MAY","Mayo"],["JUN","Junio"],["JUL","Julio"],["AGO","Agosto"],["SEP","Septiembre"],["OCT","Octubre"],["NOV","Noviembre"],["DIC","Diciembre"]];
	var letrasArray = ["L","M","MI","J","V","S","D"];
	var dayArray = ["7","1","2","3","4","5","6"];
	$(document).ready(function() 
	{
		$(document).on('click','.calendar-day.have-events',activateDay);
		$(document).on('click','.specific-day',activatecalendar);
		$(document).on('click','.calendar-month-view-arrow',offsetcalendar);
		$(window).resize(calendarScale);
		$(".calendar").calendar({
			"2013910": {
				"": {
					idevento: ""
				}
			}
		});
		calendarSet();
		calendarScale();
		
		
		$('body').on('click', '.colorbox', function(e) 
		{
			e.preventDefault();
			$.colorbox({href:$(this).attr('href'), open:true,iframe:true,innerWidth:"600px",innerHeight:"340px",overlayClose:false,onClosed:function() { location.reload(true); } });
			return false;
		});
		
		
		
	});
	</script>
	
	
	
	<!--<script type="text/javascript">
		var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
		/* document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));*/
	</script>-->
	<script type="text/javascript">
	try {
		var pageTracker = _gat._getTracker("UA-266167-20");
		pageTracker._setDomainName(".martiniglesias.eu");
		pageTracker._trackPageview();
	} catch(err) {}</script>

</body>
</html>